home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-08-21 | 8.3 KB | 357 lines | [TEXT/MSET] |
- \ Speech Manager exerciser
- \ This file requires several things to run.
- \ 1) The new version of "calls" I bundled with this package
- \ 2) The file SpeechMgr
- \ 3) The installation of the Speech Manager extension from Apple.
- \
- \ If you have these things, then this program should demonstrate the speech
- \ capabilites in both the Speech Manager, and, hence, now in Mops.
- \
- \ Note that there is little error checking in this file. If you do not have
- \ the Speech Manager extension installed, you will more than likely experience
- \ the system crashing.
- \
- \ Greg Haverkamp
-
- need Utility Code
- need SpeechMgr
-
- scon simpleString "This is just a simple string."
- scon longString "The Chris Cunningham case poses an interesting motivational problem for the management consultant."
- scon voiceTest "The Voice #"
- scon RateTest "Demonstrating the setRate feature."
- scon PitchTest "Demonstrating the setPitch feature."
- scon StopTest "Ridiculously gargantuan words."
- scon SentenceTest "Two sentences. That is what I have."
- scon TwoChannels "I can speak on multiple channels."
- scon ProsodyCheck "Listen to the end of the sentence."
- scon PreflightCheck "Let us check the preflight..."
- scon phonemeText "This is a 44 Magnum, the most powerful handgun..."
- scon infoCheck "This is a test... this is only a test..."
-
- 0 value theObject
-
- talker MySpeaker
- string theString
-
- : ShowVersion
- ." This speech manager version: " SpeechManagerVersion . cr
- ;
-
- : ShowNumberOfVoices
- ." Present number of voices available: " Voices: MySpeaker
- . cr drop
- ;
-
- : AmIBusyWithSpeech?
- IsMySpeechBusy? dup
- nif
- ." I am not currently speaking " drop
- else
- ." I have " . ." speech process(es) busy."
- then
- cr
- ;
-
- : IsAnyoneBusyWithSpeech?
- IsAnySpeechBusy? dup
- nif
- ." No one is trying to speak on this Macintosh." drop
- else
- ." There is/are " . ." speech process(es) in action on this Mac."
- then
- cr
- ;
-
- : SaySimpleString
- ." This is just a simple string." cr
- simpleString put: mySpeaker sayit: mySpeaker drop
- ;
-
- : OpenANewChannel \ This should be channel 0
- 1 getAVoice: mySpeaker NewChannel: mySpeaker drop
- ;
-
- : SpeaktoThisNewChannel
- ." This is a longer string." cr
- longString put: mySpeaker 0 speakToChannel: mySpeaker drop
- ;
-
- : LoopAndIsBusy?
- 10 0 do
- ." " AmIBusyWithSpeech?
- WaitASec
- loop
- ;
-
- : SpeakOfChrisCunningham
- OpenANewChannel
- SpeakToThisNewChannel
- ;
- : waitkey
- cr ." Press a <key> to continue" key drop cr cr cr cls ;
-
- : Introduction
- cls
- ." Welcome to the Macintosh Speech Manager." cr cr
- ." This demonstration will show some of the features" cr
- ." of the manager, and it will let you know what you can" cr
- ." do with the manager under Mops." cr cr cr
- ." Greg Haverkamp." cr
- ." gh1w@andrew.cmu.edu, dietcoke+@cmu.edu" cr cr cr
- waitkey
- ;
-
- : WaitWithCount { / count -- }
- cr cr cr ." I am waiting for this speech to end." 0 -> count
- begin
- 1 ++> count count .
- IsMySpeechBusy?
- WaitASec
- nuntil
- ;
-
- : Wait
- begin
- IsMySpeechBusy?
- nuntil
- ;
-
- : DisposingChannel
- ." To alleviate memory problems, I am disposing of current channel."
- cr
- ;
-
- : GettingAVoice ( -- )
- ." I am getting voice #" i . cr
- ;
-
- : GettingANewChannel
- ." I am getting a new channel for the above voice."
- cr
- ;
-
- : SpeakingToText
- ." Speaking using SpeakText."
- cr
- ;
-
- : SpeakingAtRate
- 0 getRate: mySpeaker
- ." Speaking rate is " swap . ." and 1/" . drop ." WPM." cr
- ;
-
- : SpeakingAtPitch
- 0 getRate: mySpeaker
- ." Speaking pitch is " swap . ." and 1/" . drop ." ." cr
- ;
-
-
- : DemoVoices
- voices: mySpeaker 1+ swap drop 1 do
- DisposingChannel 0 DisposeChannel: mySpeaker drop
- voiceTest put: theString
- i pad NumberToString add: theString reset: theString
- get: theString put: MySpeaker
- GettingAVoice i getAVoice: mySpeaker drop
- GettingANewChannel NewChannel: mySpeaker drop
- SpeakingToText 0 speakToChannel: MySpeaker drop
- wait
- cr cr
- loop
- ;
-
- : DemoRates
- RateTest put: theString
- print: theString cr cr
- 0 DisposeChannel: mySpeaker drop
- 1 getAVoice: mySpeaker drop
- NewChannel: mySpeaker drop
- RateTest put: mySpeaker
- 200 40 do
- 0 0 i setRate: mySpeaker drop
- ." This Rate is: " 0 getRate: mySpeaker . cr drop drop
- 0 speaktoChannel: mySpeaker drop wait
- 28 +loop
- ;
-
- : DemoPitches
- PitchTest put: theString
- print: theString cr cr
- 0 DisposeChannel: myspeaker drop
- 1 getAVoice: mySpeaker drop
- NewChannel: mySpeaker drop
- PitchTest put: mySpeaker
- 130 20 do
- 0 0 i setPitch: mySpeaker drop
- ." This pitch is: " 0 getPitch: mySpeaker . cr drop drop
- 0 speakToChannel: mySpeaker drop wait
- 15 +loop
- ;
-
-
- \ There seems to be some problems with the stopSpeechAt and the
- \ PauseSpeechAt functions. I am not sure what the problem is,
- \ but I cannot seem to get them to work.
- : ShowAStop
- ." We can also selectively halt speech." cr cr
- 0 DisposeChannel: myspeaker drop
- 1 getAVoice: mySpeaker drop
- NewChannel: mySpeaker drop
- 0 0 68 setRate: mySpeaker drop
- stopTest put: mySpeaker
- ." Wait 1 second and stop immediately..." cr
- stopTest type
- 0 speakToChannel: mySpeaker drop 1 waitfor#secs
- 0 kImmediate pause: mySpeaker drop
- cr cr 1 waitfor#secs 0 continue: mySpeaker drop wait
- ." Wait 1 second and stop at end of word..." cr
- stopTest type
- stopTest put: mySpeaker
- 0 speakToChannel: mySpeaker drop 1 waitfor#secs
- 0 kEndOfWord pause: mySpeaker drop
- cr cr 2 waitfor#secs 0 continue: mySpeaker drop wait
- ." Wait 1 seconds and stop at end of sentence..." cr
- SentenceTest type
- SentenceTest put: mySpeaker
- 0 speakToChannel: mySpeaker drop 1 waitfor#secs
- 0 kEndOfSentence pause: MySpeaker drop 2 waitfor#secs
- 0 continue: mySpeaker drop
- cr cr
- ;
-
- : TryTwoVoices
- 0 DisposeChannel: myspeaker drop
- 1 getAVoice: mySpeaker drop
- NewChannel: mySpeaker drop
- 9 GetAVoice: mySpeaker drop
- NewChannel: mySpeaker drop
- ." I am now speaking on channel 0."
- TwoChannels put: mySpeaker 0 speakToChannel: mySpeaker drop
- wait
- cr cr cr ." Now, I am speaking on channel 1."
- TwoChannels put: mySpeaker 1 speakToChannel: mySpeaker drop
- wait
- 1 DisposeChannel: mySpeaker drop
- ;
-
- : CheckProsody
- 0 disposeChannel: mySpeaker drop
- 3 getAVoice: mySpeaker drop
- ." Switched to voice #3." cr cr
- NewChannel: mySpeaker drop
- prosodyCheck put: mySpeaker
- ." Speaking without prosody." cr cr
- prosodyCheck type cr cr
- 0 kNoEndingProsody SpeakWithOptions: mySpeaker drop wait
- ." Speaking with prosody... Not much difference, eh?" cr cr
- prosodycheck type cr cr
- 0 0 SpeakWithOptions: mySpeaker drop wait
- ;
-
- : CheckPreFlight
- ." Trying to run with preflight." cr cr
- 0 disposeChannel: mySpeaker drop
- 2 getAVoice: mySpeaker drop
- newChannel: mySpeaker drop
- PreflightCheck put: MySpeaker
- 0 kPreflightThenPause SpeakWithOptions: mySpeaker drop
- ." Pausing." cr cr AmIBusyWithSpeech? 3 waitfor#secs
- 0 continue: mySpeaker drop
- wait
- ;
-
- : CheckConvert
- ." This converts our text to phonemes." cr cr
- ." Here is our text:" cr
- phonemeText type cr cr
- ." Here are the phonemes:" cr
- phonemeText put: mySpeaker
- 0 TextToPhonemes: mySpeaker
- getPhonemes: mySpeaker type cr cr cr
- ;
-
- : ShowTheInfoBlock
- theObject busy?: **
- if
- ." Speech is busy." cr
- else
- ." Speech is not busy." cr
- then
- theObject paused?: **
- if
- ." Speech is paused." cr
- else
- ." Speech is not paused." cr
- then
- theObject bytesLeft?: **
- . ." bytes left in buffer." cr
- theObject code?: **
- ." Current phoneme code: " . cr
- ;
-
-
- \ Do note that this is only one of the available tests... See the Speech
- \ Manager Doc for more info on this.
- : CheckGetInfo
- ." This shows the ability to get information about the current speech."
- cr cr
- 0 disposeChannel: mySpeaker drop
- 1 getAVoice: mySpeaker drop
- newChannel: mySpeaker drop
- InfoCheck put: mySpeaker
- 0 speakToChannel: mySpeaker drop waitasec
- 0 kImmediate pause: mySpeaker drop
- 0 soStatus GetInfo: mySpeaker
- waitasec
- -> theObject drop
- ShowTheInfoBlock
- 2 waitfor#secs
- 0 continue: mySpeaker drop
- waitasec
- 0 soStatus GetInfo: mySpeaker
- -> theObject drop
- cr cr cr
- ShowTheInfoBlock
- ;
-
- : go
- new: mySpeaker
- Introduction
- ShowVersion
- ShowNumberOfVoices
- AmIBusyWithSpeech?
- IsAnyoneBusyWithSpeech?
- waitkey
- SaySimpleString
- WaitWithCount
- waitkey
- SpeakOfChrisCunningham
- LoopAndIsBusy?
- waitkey
- DemoVoices
- waitkey
- DemoRates
- waitkey
- DemoPitches
- waitkey
-
- \ I have not been able to get the StopSpeechAt or the
- \ PauseSpeechAt calls to work properly for me, so I have commented out
- \ their demos.
- \ ShowAStop
- \ waitkey
-
- TryTwoVoices
- waitkey
- CheckProsody
- waitkey
- CheckPreFlight
- waitkey
- CheckConvert
- waitkey
- CheckGetInfo
- waitkey
- cr cr ." That's it for now."
- ;
-